package com.zzyl.controller;
import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.dto.ProjectPlanDto;
import com.zzyl.entity.NursingProjectPlan;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import io.swagger.annotations.ApiOperation;
import jdk.jshell.Snippet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/nursing/plan")
public class NursingPlanController {
    @Autowired
    private NursingPlanService nursingPlanService;
    @GetMapping("/search")
    @ApiOperation("条件分页查询所有护理计划")
    public ResponseResult <PageResponse<NursingPlanVo>>findAllByPage(
            String name ,
            Integer status,
           @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
           @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize){
        PageResponse<NursingPlanVo> nursingPlanVo= nursingPlanService.findAllByPage(name,status,pageNum,pageSize);
        return ResponseResult.success(nursingPlanVo);
    }
    @GetMapping("/{id}")
    @ApiOperation("根据id查询 查看时候回显")
    public ResponseResult<NursingPlanVo> selectById(@PathVariable Long id){
         NursingPlanVo nursingPlanVo= nursingPlanService.selectById(id);
         return ResponseResult.success(nursingPlanVo);
    }
    @PostMapping
    @ApiOperation("新增护理计划")
    public ResponseResult save(@RequestBody NursingPlanDto nursingPlanDto){
        nursingPlanService.save(nursingPlanDto);
        return ResponseResult.success();
    }
    @PutMapping("/{id}")
    @ApiOperation("修改护理计划")
    public ResponseResult updateById(
             @RequestBody  NursingPlanDto nursingPlanDto
     ){
        nursingPlanService.updateById( nursingPlanDto);
        return ResponseResult.success();
    }
    @DeleteMapping("/{id}")
    @ApiOperation("通过id删除护理计划")
    public  ResponseResult deleteById(@PathVariable Long id){
        nursingPlanService.deleteById(id);
        return ResponseResult.success();
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation("根据id修改状态")
    public ResponseResult updateStatusById(
            @PathVariable Long id,
            @PathVariable Integer status
    ){
        nursingPlanService.updateStatusById(id,status);
        return ResponseResult.success();
    }
}
